<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        标题：<input type="text" v-model="title" /> 价格：<input type="text" v-model="price" />
        <button @click="add">添加</button>
        <table>
            <tr>
                <th>图书名字</th>
                <th>价格</th>
                <th>操作</th>
            </tr>
            <tr v-for="(item,index) in list">
                <td>{{item.title}}</td>
                <td>{{item.price}}</td>
                <td><button @click="remove(index)">删除</button></td>
            </tr>
        </table>
    </div>
    <script src="vue-2.4.0.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                list: [{
                    title: "vuejs从入门到秃头",
                    price: 200,
                }, {
                    title: "技术大牛是怎么炼成的",
                    price: 100,
                }, {
                    title: "孟晚舟姐姐回国了",
                    price: 10000000,
                }, {
                    title: "华为二公主出道了",
                    price: 500,
                }, {
                    title: "下雨了",
                    price: 500,
                }, ],
                price: "",
                title: "",
            },
            methods: {
                add() {
                    this.list.push({
                        title: this.title,
                        price: this.price,
                    });
                    this.title = "";
                    this.price = "";
                },
                remove(index) {
                    this.list.splice(index, 1);
                },
            },
        });
    </script>
</body>

</html>